package club.banyuan;

public class ReverseHelloMultithreaded extends Thread {
    private int id;

    public ReverseHelloMultithreaded(int id) {
        this.id = id;
    }

    @Override
    public void run() {
        System.out.println("Hello from thread " + id);
        if (id == 1) {
            return;
        }
        ReverseHelloMultithreaded thread = new ReverseHelloMultithreaded(id - 1);
        thread.start();
    }

    public static void doReverseHello() {
        ReverseHelloMultithreaded thread = new ReverseHelloMultithreaded(50);
        thread.start();
    }

    public static void main(String[] args) {
        doReverseHello();
    }
}
